<?php
namespace app\admin\model;

use alipay\aop\AlipayConfig;
use alipay\aop\AopCertClient;
use alipay\aop\AopClient;

use alipay\aop\request\AlipayFundAccountQueryRequest;

use alipay\aop\request\AlipayFundTransCommonQueryRequest;


use alipay\aop\request\AlipayFundTransToaccountTransferRequest;
use alipay\aop\request\AlipayFundTransTobankTransferRequest;
use alipay\aop\request\AlipayFundTransUniTransferRequest;



class Alipay
{
    public $privateKey = "<-- 请填写您的应用私钥，例如：MIIEvQIBADANB ... ... -->";
    public $alipayPublicKey = "<-- 请填写您的支付宝公钥，例如：MIIBIjANBg... -->";

    public $appid = '2021004135673208';

    public function test(){
        $alipayConfig = new AlipayConfig();
        $alipayConfig->setServerUrl("https://openapi.alipay.com/gateway.do");
        $alipayConfig->setAppId("2021004135673208");
        $alipayConfig->setPrivateKey($this->privateKey);
        $alipayConfig->setFormat("json");
        $alipayConfig->setAlipayPublicKey($this->alipayPublicKey);
        $alipayConfig->setCharset("UTF8");
        $alipayConfig->setSignType("RSA2");
        $alipayClient = new AopClient($alipayConfig);
        $request = new AlipayFundAccountQueryRequest();
        $request->setBizContent("{".
            "\"alipay_user_id\":\"2088301409188095\",".
            "\"account_type\":\"ACCTRANS_ACCOUNT\"".
            "}");
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        if(!empty($response->code)&&$response->code==10000){
            echo("调用成功");
        }
        else{
            echo("调用失败");
        }
    }

    public function test2(){
        // 初始化SDK
        $alipayClient = new AopClient($this->getAlipayConfig());
        // 构造请求参数以调用接口
        $request = new AlipayFundTransCommonQueryRequest();
        $model = array();

        // 设置描述特定的业务场景
        $model['biz_scene'] = "PERSONAL_PAY";

        // 设置支付宝支付资金流水号
        $model['pay_fund_order_id'] = "20190801110070001506380000251556";

        // 设置销售产品码
        $model['product_code'] = "STD_RED_PACKET";

        // 设置商户转账唯一订单号
        $model['out_biz_no'] = "201808080001";

        // 设置支付宝转账单据号
        $model['order_id'] = "20190801110070000006380000250621";

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        dd($response);
        if(!empty($response->code)&&$response->code==10000){
            echo("调用成功");
        }
        else{
            echo("调用失败");
        }

    }

    //转账银行卡
    public function transferToCard(){
        // 初始化SDK
        $alipayClient = new AopCertClient($this->getAlipayConfig());
        // 构造请求参数以调用接口
        $request = new AlipayFundTransUniTransferRequest();
        $model = array();

        // 设置转账业务的标题
        $model['order_title'] = "转账标题";

        // 设置描述特定的业务场景
        $model['biz_scene'] = "DIRECT_TRANSFER";

        // 设置签名信息
        $signData = array();
        $signData['ori_sign'] = "EqHFP0z4a9iaQ1ep==";
        $signData['partner_id'] = "签名被授权方支付宝账号ID";
        $signData['ori_app_id'] = $this->appid;//"2021000185629012";
        $signData['ori_out_biz_no'] = "201806300001";
        $signData['ori_sign_type'] = "RSA2";
        $signData['ori_char_set'] = "UTF-8";
        $model['sign_data'] = $signData;

        // 设置转账业务请求的扩展参数
        $model['business_params'] = "{\"withdraw_timeliness\":\"T0\", \"sub_merchant_info\":\" {\\\"subMerchantName\\\":\\\"测试企业名称\\\",\\\"subMerchantMCC\\\":\\\"12345\\\"}\"} 注意：withdraw_timeliness 为转账到银行卡的预期到账时间，不传默认T+1到账。";

        // 设置业务备注
        $model['remark'] = "单笔转账";

        // 设置商家侧唯一订单号
        $model['out_biz_no'] = "201806300001";

        // 设置订单总金额
        $model['trans_amount'] = "0.1";

        // 设置业务产品码
        $model['product_code'] = "TRANS_ACCOUNT_NO_PWD";

        // 设置收款方信息
        $payeeInfo = array();
        $payeeInfo['identity'] = "6214832349601869";
        $payeeInfo['name'] = "庄延超";
        $payeeInfo['identity_type'] = "BANKCARD_ACCOUNT";
        $model['payee_info'] = $payeeInfo;

        // 设置原支付宝业务单号
        $model['original_order_id'] = "20190620110075000006640000063056";

        $request->setBizContent(json_encode($model,JSON_UNESCAPED_UNICODE));
        $responseResult = $alipayClient->execute($request);
        $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
        $response = $responseResult->$responseApiName;
        dd($response);
        if(!empty($response->code)&&$response->code==10000){
            echo("调用成功");
        }
        else{
            echo("调用失败");
        }
    }

    public function transTobank(){
        // 初始化AopClient
//        $aop = new AopClient();
//        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
//        $aop->appId = $appId;
//        $aop->rsaPrivateKey = $privateKey;
//        $aop->alipayrsaPublicKey = $publicKey;
//        $aop->apiVersion = '1.0';
//        $aop->signType = 'RSA2';
//        $aop->postCharset = 'UTF-8';
//        $aop->format = 'json';

        // 初始化SDK
        $aop = new AopClient($this->getAlipayConfig());

        // 设置转账参数
        $outBizNo = '201806300001'; // 商户转账唯一订单号
        $payeeAccount = '6214832349601869'; // 收款方银行卡账号
        $payeeName = '庄延超'; // 收款方真实姓名
        $amount = '0.01'; // 转账金额
        $bankName = '招商银行'; // 收款方开户行名称

        // 创建转账请求
        $request = new AlipayFundTransTobankTransferRequest();
        $request->setBizContent(json_encode([
            'out_biz_no' => $outBizNo,
            'payee_account' => $payeeAccount,
            'payee_real_name' => $payeeName,
            'amount' => $amount,
            'bank_name' => $bankName,
        ]));

        // 发送转账请求
        $result = $aop->execute($request);
        dd($result);
        if (isset($result->alipay_fund_trans_tobank_transfer_response)) {
            $response = $result->alipay_fund_trans_tobank_transfer_response;
            if ($response->code == '10000') {
                echo '转账成功';
            } else {
                echo '转账失败，错误码：' . $response->code . '，错误信息：' . $response->sub_msg;
            }
        } else {
            echo '请求失败';
        }
    }

    public function transTobank2(){
        $aop = new AopClient ();
        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
        $aop->appId = $this->appid;
        $aop->rsaPrivateKey = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqpVOlCbK0iSjkQ+DXc8N+IODSWqTLjkHoz08wYHxz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49dUK7cH0oyCJ9t3qI1akFTqfDkDGIInXZgvRznKm5IwPiziqHWjCCz/MrHqw2dMTUSUXOxeP9G+ESeeWDspWlRG4LVPGJps6NQDOgMXdPQKBgFRBJwu0kW8B5niQ1X9yp8nSgJX1sNmQchVl542YXqKuPxJVPtwTvOvUjm7vWly8QVSyMYz4EemNlF7JVK/HC49QIy7cZdhvFyvCx4tppiMw9csKKyRY2xxq8ROFbGU2tmWnCA1lNhd8xDmzv+xFGk8BdO6FUHoyyjQPQphp1hUBAoGAWuDNYykNta6y8T4SamfphLtlG2KkDo9KoHrTJHEdJ+ca5NQiPUTdMRRPiwgibeEJZLM0hxXM4Xlbb3GaDpeqHPK9cioCc7VftU3KMhd9DUPXSKLp+Whof5K96G74yy1MOw9Tp7VXTSVuZPaOJsgPnrOFoacdZCsr0buZn6SoUjY=';
        $aop->alipayrsaPublicKey='MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjhJ7dtRyJXm7yglINThmWWqLmFxeAappeHMAwgUGEu//y3NoqJhhMa+c2l4Jxxye8f50vVZGOpvJgRDzuedrMOUZ3huDRFIb/MyjIwKbnqRSOGikzP2ejOlFO9wu896fNR88rEbOLsNE9Gb5cmAqAZEAgszKe+qz/xIgso+c5QyuRJoml2nmaFs7X6j3EwUj/PwzCzkGtTPEU7k1gYWqPoaCCIITf/ZSYVjSILN4Lg63YsOTYMbOOT5D992QVF4izwmXdqIwTOXKvI/QmcYo05kgOOphUEuU7GOeLAr6hDFhKLV0Hj5RiDAGsjWebU9efE6AqFQLJz5ptEtK0LTWswIDAQAB';
        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset='UTF-8';
        $aop->format='json';
        $request = new AlipayFundTransTobankTransferRequest ();
        $request->setBizContent("{" .
            "  \"out_biz_no\":\"3142321423432\"," .
            "  \"amount\":\"0.01\"," .
            "  \"payer_real_name\":\"庄延超\"," .
            "  \"payee_card_no\":\"6214832349601869\"," .
            "  \"payee_account_name\":\"庄延超\"," .
            "  \"payee_account_type\":\"2\"," .
            "  \"payee_inst_name\":\"招商银行\"," .
            "  \"payee_inst_province\":\"江苏省\"," .
            "  \"payee_inst_city\":\"南京\"," .
            "  \"payee_inst_branch_name\":\"新街口支行\"," .
            "  \"payee_bank_code\":\"2\"," .
            "  \"time_liness\":\"T0\"," .
            "  \"remark\":\"银行备注\"," .
            "  \"memo\":\"9\"" .
            "}");
        $result = $aop->execute ( $request);
        dd($result);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        dd($resultCode);
        if(!empty($resultCode)&&$resultCode == 10000){
            echo "成功";
        } else {
            echo "失败";
        }
    }

    public function getAlipayConfig()
    {
//        $privateKey  = '<-- 请填写您的应用私钥，例如：MIIEvQIBADANB ... ... -->';
//        $alipayPublicKey = '<-- 请填写您的支付宝公钥，例如：MIIBIjANBg... -->';
        $privateKey = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqpVOlCbK0iSjkQ+DXc8N+IODSWqTLjkHoz08wYHxzW/SMX4QN3hYaflrf8ZDB+xAaE33zV1ruub01xKDHDCnESL18Vy0UzyOqpV1SEWF76mqbl1UgiGQS3/SkRSChIEUV/O1yiCvBjj2lCUnUELCnwDEA1tce77wa5/0/aYQgB3B50O4BiF0Swzh7mV9ptGCYhUhjBo+YLguvLViN/UVHzaHOvKt1YTTwGEWP/BcSumuUkvHrsvQBF56s9129v9ZX5BU2m/cohS+ryHKPFi6ofJ47JtMZx45dNK9J8s5iZHpY6VrwFZK6MdzdZK8g0q8xEgd5ZFJc5gzwX8oJhxn3AgMBAAECggEBAIfsjIXHBct7/VBlKPE0yqDqu2mSvfVN6P3yM1eLY1XYByDQ7DTHk7+iqev7VJzOyHKc2BQ+nrXMyQPNDWu/Kn2omxYxsj0DCZvhgEXghk/X1vb8QdhaC6xlK061qVnuhFkRUGmMQZ45GK0eiuoaKTxVgDL07gE8YA7mf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ANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjhJ7dtRyJXm7yglINThmWWqLmFxeAappeHMAwgUGEu//y3NoqJhhMa+c2l4Jxxye8f50vVZGOpvJgRDzuedrMOUZ3huDRFIb/MyjIwKbnqRSOGikzP2ejOlFO9wu896fNR88rEbOLsNE9Gb5cmAqAZEAgszKe+qz/xIgso+c5QyuRJoml2nmaFs7X6j3EwUj/PwzCzkGtTPEU7k1gYWqPoaCCIITf/ZSYVjSILN4Lg63YsOTYMbOOT5D992QVF4izwmXdqIwTOXKvI/QmcYo05kgOOphUEuU7GOeLAr6hDFhKLV0Hj5RiDAGsjWebU9efE6AqFQLJz5ptEtK0LTWswIDAQAB';
//        $privateKey  = file_get_contents(app()->getRootPath() . 'public' . '/alipay/private.txt');//self::formatRsaKey(file_get_contents(app()->getRootPath() . 'public' . '/alipay/private.txt'));
//        $alipayPublicKey = file_get_contents(app()->getRootPath() . 'public' . '/alipay/alipayCertPublicKey_RSA2.crt');//self::formatRsaKey(file_get_contents(app()->getRootPath() . 'public' . '/alipay/public.txt'));
        $alipayConfig = new AlipayConfig();
        $alipayConfig->setServerUrl('https://openapi.alipay.com/gateway.do');
        $alipayConfig->setAppId($this->appid);
        $alipayConfig->setPrivateKey($privateKey);
        $alipayConfig->setFormat('json');
        $alipayConfig->setAlipayPublicKey($alipayPublicKey);
        $alipayConfig->setCharset('UTF-8');
        $alipayConfig->setSignType('RSA2');

        $alipayConfig->setAlipayPublicCertContent(file_get_contents(app()->getRootPath() . 'public' . '/alipay/alipayCertPublicKey_RSA2.crt'));
        $alipayConfig->setAppCertContent(file_get_contents(app()->getRootPath() . 'public' . '/alipay/appCertPublicKey_2021004135673208.crt'));
        $alipayConfig->setRootCertContent(file_get_contents(app()->getRootPath() . 'public' . '/alipay/alipayRootCert.crt'));

        return $alipayConfig;
    }

    /**
     * 生成密钥
     * @Author Abnermouke <abnermouke@outlook.com>
     * @Originate in Abnermouke's MBP
     * @Time 2023-04-10 00:16:32
     * @param $key
     * @param $alias
     * @return string
     */
    private static function formatRsaKey($key, $alias = 'RSA PRIVATE')
    {
        //生成pem
        $pem = "-----BEGIN $alias KEY-----\n".$key."-----END $alias KEY-----";
        //返回pem
        return $pem;
    }

    //转账到支付宝账号
    public function transToaccount($info){
        // 初始化SDK
        $aop = new AopClient($this->getAlipayConfig());

        // 设置转账参数
        $outBizNo = $info['withdraw_sn'];//'201806300002'; // 商户转账唯一订单号
        $payeeType = 'ALIPAY_LOGONID';
        $payeeAccount = $info['account'];//'13232713202'; // 收款方支付宝账号
        $payeeName = $info['name'];//'庄延超'; // 收款方真实姓名
        $amount = $info['amount'];//'0.1'; // 转账金额

        // 创建转账请求
        $request = new AlipayFundTransToaccountTransferRequest();
        $request->setBizContent(json_encode([
            'out_biz_no' => $outBizNo,
            'payee_type' => $payeeType,
            'payee_account' => $payeeAccount,
            'payee_real_name'=>$payeeName,
            'amount' => $amount,
        ]));

        $result = $aop->execute($request);
//        dd($result);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return 1;
        } else {
            return json_encode($result);
        }
    }

    public function transToaccount2(){
        $amount = request()->param('amount');
        $chargeAmount = $amount * 0.012;
        $chargeAmount = floor($chargeAmount * 100) / 100;
//        dd($chargeAmount);
        // 初始化SDK
        $aop = new AopClient($this->getAlipayConfig());

        // 设置转账参数
        $outBizNo = time();//'201806300002'; // 商户转账唯一订单号
        $payeeType = 'ALIPAY_LOGONID';
        $payeeAccount = '13414938618';//'13232713202'; // 收款方支付宝账号
        $payeeName = '庄延超'; // 收款方真实姓名
        $amount = $chargeAmount;//'0.1'; // 转账金额
        $bankName = '招商银行'; // 收款方开户行名称

        // 创建转账请求
        $request = new AlipayFundTransToaccountTransferRequest();
        $request->setBizContent(json_encode([
            'out_biz_no' => $outBizNo,
            'payee_type' => $payeeType,
            'payee_account' => $payeeAccount,
//            'payee_real_name'=>$payeeName,
            'amount' => $amount,
        ]));

//        $aop = new AopClient ();
//        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
//        $aop->appId = 'your app_id';
//        $aop->rsaPrivateKey = '请填写开发者私钥去头去尾去回车，一行字符串';
//        $aop->alipayrsaPublicKey='请填写支付宝公钥，一行字符串';
//        $aop->apiVersion = '1.0';
//        $aop->signType = 'RSA2';
//        $aop->postCharset='GBK';
//        $aop->format='json';
//        $request = new AlipayFundTransToaccountTransferRequest ();
//        $request->setBizContent("{" .
//            "  \"out_biz_no\":\"3142321423432\"," .
//            "  \"payee_type\":\"ALIPAY_LOGONID\"," .
//            "  \"payee_account\":\"13232713202\"," .
//            "  \"amount\":\"12.23\"," .
//            "  \"payer_show_name\":\"上海交通卡退款\"," .
//            "  \"payee_real_name\":\"张三\"," .
//            "  \"remark\":\"转账备注\"" .
//            "}");
        $result = $aop->execute($request);
        dd($result);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            echo "成功";
        } else {
            echo "失败";
        }
    }

    public function transToaccount3(){
        $amount = request()->param('amount');
        $chargeAmount = $amount;
//        dd($chargeAmount);
        // 初始化SDK
        $aop = new AopClient($this->getAlipayConfig());

        // 设置转账参数
        $outBizNo = time();//'201806300002'; // 商户转账唯一订单号
        $payeeType = 'ALIPAY_LOGONID';
        $payeeAccount = 'jfengkeji@126.com';//'13232713202'; // 收款方支付宝账号
        $payeeName = '黑龙江靖峰科技有限公司'; // 收款方真实姓名
        $amount = $chargeAmount;//'0.1'; // 转账金额

        // 创建转账请求
        $request = new AlipayFundTransToaccountTransferRequest();
        $request->setBizContent(json_encode([
            'out_biz_no' => $outBizNo,
            'payee_type' => $payeeType,
            'payee_account' => $payeeAccount,
            'payee_real_name'=>$payeeName,
            'amount' => $amount,
        ]));

        $result = $aop->execute($request);
        dd($result);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            echo "成功";
        } else {
            echo "失败";
        }
    }

    public function transToaccount4(){
        $amount = request()->param('amount');
//        dd($chargeAmount);
        // 初始化SDK
        $aop = new AopClient($this->getAlipayConfig());

        // 设置转账参数
        $outBizNo = time();//'201806300002'; // 商户转账唯一订单号
        $payeeType = 'ALIPAY_LOGONID';
        $payeeAccount = '13414938618';//'13232713202'; // 收款方支付宝账号

        // 创建转账请求
        $request = new AlipayFundTransToaccountTransferRequest();
        $request->setBizContent(json_encode([
            'out_biz_no' => $outBizNo,
            'payee_type' => $payeeType,
            'payee_account' => $payeeAccount,
//            'payee_real_name'=>$payeeName,
            'amount' => $amount,
        ]));

        $result = $aop->execute($request);
        dd($result);

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            echo "成功";
        } else {
            echo "失败";
        }
    }
}